namespace SqlQueryBuilder.Clauses
{
    /// <summary>
    /// Select Clause
    /// </summary>
    public class SelectClause
    {
        #region Properties

        /// <summary>
        /// Gets or sets the field to select.
        /// </summary>
        /// <value>The select clause.</value>
        public string selectClause { get; set; }

        /// <summary>
        /// Gets or sets the alias of the field.
        /// </summary>
        /// <value>The alias.</value>
        public string Alias { get; set; }

        #endregion

        #region Constructors

        /// <summary>
        /// Initializes a new instance of the <see cref="SelectClause"/> class.
        /// </summary>
        /// <param name="selectClause">The select clause.</param>
        /// 
        public SelectClause(string selectClause) : this(selectClause, "") {}
        /// <summary>
        /// Initializes a new instance of the <see cref="SelectClause"/> class.
        /// </summary>
        /// <param name="literal">The literal.</param>
        public SelectClause(SqlLiteral literal) : this(literal, "") {}

        /// <summary>
        /// Initializes a new instance of the <see cref="SelectClause"/> class.
        /// </summary>
        /// <param name="literal">The literal.</param>
        /// <param name="alias">The alias.</param>
        public SelectClause(SqlLiteral literal, string alias)
        {
            selectClause = literal.Value;
            Alias = alias;
        }

        #endregion

        /// <summary>
        /// Initializes a new instance of the <see cref="SelectClause"/> class.
        /// </summary>
        /// <param name="selectClause">The select clause.</param>
        /// <param name="alias">The alias.</param>
        public SelectClause(string selectClause, string alias)
        {
            Alias = alias;
            this.selectClause = selectClause;
        }

        /// <summary>
        /// Performs an implicit conversion from <see cref="System.String"/> to <see cref="SqlQueryBuilder.Clauses.SelectClause"/>.
        /// </summary>
        /// <param name="selectClause">The select clause.</param>
        /// <returns>The result of the conversion.</returns>
        public static implicit operator SelectClause(string selectClause)
        {
            return new SelectClause(selectClause);
        }
    }
}